import { extend } from 'umi-request';
import { message } from 'antd';

const request = extend({
  prefix: 'http://pudge.wang:3000/api',
  timeout: 1000,
});

const http = {
  get(url: string, params?: Object) {
    return request
      .get(url, {
        params: params,
      })
      .then((response) => {
        return response;
      })
      .catch((error) => {
        message.error(error.message);
      });
  },
  post(url: string, data?: Object) {
    return request
      .post(url, {
        data: data,
      })
      .then((response) => {
        return response;
      })
      .catch((error) => {
        message.error(error.message);
      });
  },
};
export default http;
